function [Demodulated_Data] = HF_DemodSoft_QAM(Complex_Rx,Rate,fadingGains,alpha,MSE_Real, MSE)
%*------------------------------ HF_DemodSoft_QAM --------------------------------------%
%
% HF_DemodSoft_QAM
%
% The fuction that de-modulate the input frame dependent on its rate, and
% hence the length of output frame length must match with the corressponding
% rate as follows:
%
%
%           Rate            |           Input Frame Length
%
%           6400           |                    1024
%           8000           |                    1280
%           9600           |                    1536
%
%*------------------------------------------------------------------------------------%
if (Rate == 6400)
    %16QAM
    M=4;

elseif (Rate == 8000)
    %32QAM
    M=5;

elseif (Rate == 9600)
    %64QAM
    M=6;

elseif (Rate == 12800)
    %64QAM
    M=6;

else disp('Error ==> Rate not supported')
end

% get the bit allocation Table for QAM 
%-----------------------------------
Table =  getBitValLoc(M);

for n = 1 : length (Complex_Rx)
    z = Complex_Rx(n);
    h = fadingGains(n);
%     h = 1;
%     h= 1/MSE_Real;
%         h= 1/ MSE;
    for m = 1:M
        % Soft value calculation (Log Likelihood Relation)
        %---------------------------------------------
        LLR(m,n)  = h*(min( abs(z-Table(1,:,m)*1).^2) - min(abs(z-Table(2,:,m)*1).^2)); 
    end
end

%==== LLR(1,:) is MSB
%==== LLR(M,:) is LSB
% then flipud(LLR(1,:))  is LSB
% then flipud(LLR(M,:))  is MSB
%

Demodulated_Data = reshape(flipud(LLR),1,[]);